﻿using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using LSA.Framework;

namespace Visuals.Panes
{
    /// <summary>
    /// Interaction logic for WordsListControl.xaml
    /// </summary>
    public partial class DocumentsListControl : UserControl
    {
        public ObservableCollection<string> AllDocuments { get; set; }

        public Action<WordInfo> Callback { get; set; }

        public DocumentsListControl(ObservableCollection<string> documents) : this()
        {
            AllDocuments = documents;
        }

        public DocumentsListControl()
        {
            AllDocuments = new ObservableCollection<string>();
            DataContext = this;
            InitializeComponent();
        }

        private void documentsPane_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            DependencyObject obj = (DependencyObject)e.OriginalSource;

            while (obj != null && obj != documentsPane)
            {
                if (obj.GetType() == typeof(ListViewItem))
                {
                    var listItem = (ListViewItem)obj;
                    var content = (string)listItem.Content;

                    //Process.Start(content);

                    break;
                }
                obj = VisualTreeHelper.GetParent(obj);
            }
        }
    }
}
